package com.example.shopdemo.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author ：Anitaxiaofeng
 * @description：
 * @create 2018-01-25
 **/
@Configuration
@Slf4j
public class ImgConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /**
         * @Description: 对文件的路径进行配置,创建一个虚拟路径/Path/** ，即只要在<img src="/Path/picName.jpg" />便可以直接引用图片
         *这是图片的物理路径  "file:/+本地图片的地址"
         * @Date： Create in 14:08 2017/12/20
         */     registry.addResourceHandler("/Path/**").addResourceLocations("file:/Users/xuwanying/test/");
         registry.addResourceHandler("/upload/**").addResourceLocations("file:/Users/xuwanying/upload/");
        super.addResourceHandlers(registry);

    }

}
